package com.guomai.app.server.provider;

import com.keke.api.PrintServiceFacade;
import org.apache.dubbo.config.annotation.DubboService;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.TimeUnit;

@DubboService(version = "1.0.0")
public class PrintService implements PrintServiceFacade {

    @Autowired
    private RedissonClient redissonClient;
    @Override
    public String sayHello(String data) {
        redissonClient.getBucket("KEY:"+data)
                .set(data, 1, TimeUnit.DAYS);

        RBucket<String> bucket = redissonClient.getBucket("KEY:"+data);

        return "RemoteCall:"+data + ".ttl"+bucket.get();
    }
}
